<!-- header -->
<th:block th:fragment="header">
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
    <meta content="IE=edge" http-equiv="X-UA-Compatible"/>
    <meta content="width=device-width, initial-scale=1" name="viewport"/>
    <meta name="Template Message" th:content="|${#execInfo.templateName} -  ${#dates.createNow()}|"/>
    <link rel="shortcut icon" th:href="|${base?:''}/favicon.ico|" type="image/x-icon"/>
    <link href="/css/bootstrap.css" rel="stylesheet" th:href="|${base?:''}/css/bootstrap.css|"/>
    <link href="/css/blog.css" rel="stylesheet" th:href="|${base?:''}/css/blog.css|"/>
</th:block>


<!-- body -->
<th:block th:fragment="body (navbar, sidebar, contentDiv)">
    <div class="blog-masthead">
        <div class="container">
            <nav class="blog-nav">
                <a th:with="isHome=(${navbar}=='home')" th:class="'blog-nav-item ' + (${isHome}?'active':'')"
                   class="blog-nav-item active"
                   th:href="(${isHome}?'#':${url.toURL('/home')})" href="./index.jj">
                    Home 首页
                </a>
                <a th:with="isDoc=(${navbar}=='doc')" th:class="'blog-nav-item ' + (${isDoc}?'active':'')"
                   class="blog-nav-item "
                   th:href="(${isDoc}?'#':${url.toURL('/doc')})" href="./doc.jj">
                    Documentation 文档
                </a>
                <a th:with="isDownloads=(${navbar}=='downloads')"
                   th:class="'blog-nav-item ' + (${isDownloads}?'active':'')" class="blog-nav-item"
                   th:href="(${isDownloads}?'#':${url.toURL('/downloads')})" href="./downloads.jj">
                    Downloads 下载
                </a>
                <a th:with="isAbout=(${navbar}=='about')" th:class="'blog-nav-item ' + (${isAbout}?'active':'')"
                   class="blog-nav-item"
                   th:href="(${isAbout}?'#':${url.toURL('/about')})" href="./about.jj">
                    About 关于
                </a>
            </nav>
        </div>
    </div>
    <div class="container">
        <th:block th:replace="${contentDiv}"/>
    </div>
</th:block>


<!-- footer -->
<th:block th:fragment="footer (fixedBottom?:false)">
    <footer class="blog-footer">
        <p>&copy; 2019
            <a th:href="${url.toURL('/index')}">JRouter.NET</a>
        </p>
        <p>
            <a href="#">Back to top</a>
            [(${_executionTime?:0})] ms
        </p>
    </footer>
    <script type="text/javascript" th:src="|${base?:''}/js/jquery.js|" src="/js/jquery.js"></script>
    <script type="text/javascript" th:src="|${base?:''}/js/bootstrap.js|" src="/js/bootstrap.js"></script>
    <script type="text/javascript" th:src="|${base?:''}/js/js.cookie.js|" src="/js/js.cookie.js"></script>
    <script type="text/javascript">
        //<![CDATA[
        var MT_Cookie;
        $(document).ready(function () {
            //mouses tacker get/set from cookie
            MT_Cookie = {
                cookieKey: "mt",
                set: function (x, y) {
                    if ($.isNumeric(x) && $.isNumeric(y)) {
                        var mts = MT_Cookie.get();
                        //去重
                        for (var i = 0; i < mts.length; i++) {
                            var p = mts[i];
                            if (p[0] === x && p[1] === y) {
                                mts.splice(i, 1);
                            }
                        }
                        //添加至开头
                        mts.unshift([x, y]);
                        while (mts.length > 128) {
                            //删末尾
                            mts.pop();
                        }
                        //console.info(x + "," + y);
                        Cookies.set(MT_Cookie.cookieKey, mts);
                    }
                },
                get: function () {
                    var mts = Cookies.getJSON(MT_Cookie.cookieKey) || [];
                    if (!$.isArray(mts)) {
                        mts = [];
                    }
                    if (mts.length === 0) {
                        //清理以避免读错cookie
                        MT_Cookie.reset();
                        mts = [];
                    }
                    return mts;
                },
                reset: function () {
                    Cookies.remove(MT_Cookie.cookieKey);
                    Cookies.remove(MT_Cookie.cookieKey, {path: ''});
                }
            };
            var MT = {
                curPoint: [],
                checkPoint: [],
                _cumulative: 0,
                _init_: function () {
                    $(document).mousemove(function (e) {
                        //console.info(e);
                        MT.curPoint = [e.screenX, e.screenY];
                        MT._cumulative = 0;
                    });
                    setInterval(function () {
                        //mouse hover
                        if (MT.curPoint[0] === MT.checkPoint[0] && MT.curPoint[1] === MT.checkPoint[1]) {
                            if (MT._cumulative++ >= 7) {
//                                MT.lastHover = MT.curHover;
                                MT_Cookie.set(MT.curPoint[0], MT.curPoint[1]);
                            }
                        } else {
                            MT.checkPoint = MT.curPoint;
                            MT._cumulative = 0;
                        }
                    }, 100);
                }()
            };
        });
        //]]>
    </script>
</th:block>